(function(){
    function Step( type, name, iconLink){
        this.type = type;
        this.name = name;
        this.iconLink = iconLink;
    }

    //获取一个石头剪刀布
    Step.prototype.createStep = function(){
        let num = Tools.getRandom(1,3);
        let name = "";
        let iconLink = "";
        switch(num){
            case 1: 
              name = "石头";
              iconLink = './img/shitou.png';
              break;
            case 2:
              name = "剪刀";
              iconLink = './img/jiandao.png';
              break;
            case 3:
              name = "布";
              iconLink = './img/bu.png';
              break;
            default:
              break;
        }
        return new Step(num, name, iconLink); 
    }

    Step.prototype.render = function(doc){
        let node = `<img src="${this.iconLink}"><p>${this.name}</p></div>`;
        doc.innerHTML = node;
    }

    /**
     * 
     * @param {敌方} stepA 
     * @param {我的} stepB 
     */
    Step.prototype.compare = function(stepA, stepB){
        // 获取step的type
        let typeA = stepA.type;
        let typeB = stepB.type;

        // 石头1 > 剪刀2 > 布3 > 石头1
        if(typeA == typeB){
           return "平局";
        }else if(Math.abs(typeA - typeB) == 1){
           return typeA - typeB > 0 ? "赢" : "输";  
        }else{
           return typeA - typeB > 0 ? "输" : "赢";
        }
    }
    window.Step = Step;
})();